<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <canvas id="canvas" width="400" height="400"></canvas>
    <script src="utils.js"></script>
    <script src="ball.js"></script>
    <script>
        window.onload = function () {
            var canvas = document.getElementById('canvas'),
                context = canvas.getContext('2d'),
                ball = new Ball(),
                angle = 0,
                centerScale = 1,
                range = 0.5,
                speed = 0.05

            ball.x = canvas.width / 2
            ball.y = canvas.height / 2

            function drawFrame() {
                window.requestAnimationFrame(drawFrame, canvas)
                context.clearRect(0, 0, canvas.width, canvas.height)

                ball.scaleX = ball.scyle = centerScale + Math.sin(angle) * range
                angle += speed
                ball.draw(context)
            }

            drawFrame()



        }
    </script>
</body>

</html>